<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>杨澎锴的作业实践26</title>
    <!-- 开发环境版本，包含了有帮助的命令行警告 -->
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  </head>
  <body>
    <header>
      <!-- 学习的理解、验证、应用 -->
      <h1>VUE.JS的基本概念</h1>
      <h2>API:watch属性——侦听变量的变化</h2>
      <h2>vuejs条件渲染</h2>
    </header>
    <main>
      <div id="app">
        <p>{{ message }}</p>
        <p>{{ slogan }}</p>
        <!-- v-show执行真假值 -->
        <p v-show="login">今天的收入：？？？</p>
        <p v-if="location =='美国'">美金</p>
        <p v-else-if="location =='中国'">人民币</p>
        <p v-else="location">其他</p>
      </div>
    </main>
    <script>
      var dataFromOutside = new Date();
      var app = new Vue({
        el: "#app",
        data: {
          message: "这个是来自vuejs的数据",
          location: "美国",
        },
        watch: {
          message: function (newVal, oldVal) {
            console.log("新的值是:", newVal);
            console.log("旧的值是：", oldVal);
          },
        },
        computed: {
          slogan: function () {
            return this.message + "，什么就是实力，" + dataFromOutside;
          },
          login: function () {
            // login判断为flase
            return false;
          },
        },
      });
    </script>
  </body>
</html>
